#include "XCompareThread.h"

XCompareThread::XCompareThread(QObject * p)
	:QThread(p), m_bCancel(false)
{

}

void XCompareThread::SetCompairDir(QString strLeft, QString strRight)
{
	QMutexLocker m(&m_mutex);
	m_compair.m_strLeft = strLeft;
	m_compair.m_strRight = strRight;
}

void XCompareThread::run()
{
	while (!m_bCancel)
	{
		QMutexLocker m(&m_mutex);
		if (m_compair.IsNull())
		{
			yieldCurrentThread();
			continue;
		}
		auto compareData = m_compair.Compare();
		emit sigCompairResult(QVariant::fromValue(compareData));
		m_compair.m_strLeft.clear();
		m_compair.m_strRight.clear();
	}
}